/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package view;

import java.awt.Component;
import java.awt.Dimension;
import java.awt.image.BufferedImage;

import javax.imageio.ImageIO;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import model.Contact;

/**
 *
 * @author hbriand
 * 
 * @class ContactDetailedViewPanel
 * @desc The detailed view of a contact
 */
public class ContactDetailedViewPanel extends JPanel{

    /**
	 * 
	 */
	private static final long serialVersionUID = 4721107721518833456L;
	private Contact contact;

    public ContactDetailedViewPanel() {
        this.contact = null;

    }

    @Override
    public Dimension getMinimumSize()
    {
        return new Dimension(266, 600);
    }

    public void setContact(Contact selected) {
        this.contact = selected;
        this.redraw();
    }

    public void myHide() {
        this.setVisible(false);
    }

    public void redraw() {
        this.removeAll();
        if (this.contact == null) return;
        this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
        this.setMinimumSize(new Dimension(266, 600));
        this.setPreferredSize(new Dimension(266,600));


        JLabel image = new JLabel(this.contact.getPhoto());
        image.setText("plop");
        image.setSize(30, 30);
        image.setBorder(BorderFactory.createBevelBorder(2));
        image.setAlignmentY(Component.CENTER_ALIGNMENT);
        image.setAlignmentX(Component.CENTER_ALIGNMENT);
        this.add(image);

        JLabel fullName = new JLabel(this.contact.fullName());
        fullName.setSize(266, 30);
        fullName.setAlignmentY(Component.CENTER_ALIGNMENT);
        fullName.setAlignmentX(Component.CENTER_ALIGNMENT);
        this.add(fullName);

        JLabel phone = new JLabel(this.contact.getPhone());
        phone.setAlignmentY(Component.CENTER_ALIGNMENT);
        phone.setAlignmentX(Component.CENTER_ALIGNMENT);
        this.add(phone);

        JLabel email = new JLabel(this.contact.getEmail());
        email.setAlignmentY(Component.CENTER_ALIGNMENT);
        email.setAlignmentX(Component.CENTER_ALIGNMENT);
        this.add(email);
    }

    public boolean hasContact() {
        return this.contact!=null;
    }

}
